package listbyorder.access001_100.test82;

import listbyorder.utils.ListNode;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/5 8:45
 */
public class Solution1 {

    // 神奇的递归
    public ListNode deleteDuplicates(ListNode head) {
        if (head == null || head.next == null) return head;
        if (head.next.val == head.val) {
            ListNode temp = head;
            while (temp.next != null && temp.next.val == head.val) {
                temp = temp.next;
            }
            return deleteDuplicates(temp.next);
        }
        head.next = deleteDuplicates(head.next);
        return head;
    }
}
